package week08.day01;
/*
 * 向上转型：子类对象当作父类对象来引用
 */
public class 向上转型 {
    public static void main(String[] args) {
        Fruit fruit = new Fruit();
        Apple apple = new Apple();
        Fruit fruit1 = new Apple(); //向上转型
        fruit.eat();
        fruit1.eat();
        apple.eat();
    }
}

class Fruit {
    String name;
    public void eat(){
        System.out.println("吃水果补充维生素");
    }
}

class Apple extends Fruit{
    public void eat(){
        System.out.println("吃苹果");
    }
}